/*
 * Copyright (C) 2019 xuexiangjys(xuexiangjys@163.com)
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *       http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 *
 */

package com.xuexiang.yoyo.fragment.yey1;

import android.annotation.SuppressLint;
import android.view.LayoutInflater;
import android.view.ViewGroup;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.xuexiang.yoyo.core.BaseFragment;
import com.xuexiang.yoyo.databinding.FragmentAbcBinding;
import com.xuexiang.xpage.annotation.Page;
import com.xuexiang.xpage.enums.CoreAnim;
import com.xuexiang.xui.widget.actionbar.TitleBar;

/**
 * @author liuxiangfei
 * @since 2023-07-24 00:19
 */
@Page(anim = CoreAnim.none)
public class AbcFragment extends BaseFragment<FragmentAbcBinding> {


    @NonNull
    @Override
    protected FragmentAbcBinding viewBindingInflate(@NonNull LayoutInflater inflater, @Nullable ViewGroup container, boolean attachToRoot) {
        return FragmentAbcBinding.inflate(inflater, container, attachToRoot);
    }

    /**
     * @return 返回为 null意为不需要导航栏
     */
    @Override
    protected TitleBar initTitle() {

        return null;
    }

    /**
     * 初始化控件
     */
    @Override
    protected void initViews() {
        binding.btnAbc.setText(YeyUtil.abc(index++));
    }



    int index = 0;
    @SuppressLint("ResourceAsColor")
    @Override
    protected void initListeners() {
        super.initListeners();
        binding.btnAbc.setOnClickListener(v -> {
            if(index>=YeyUtil.CHARS.length())index=0;
            binding.btnAbc.setText(YeyUtil.abc(index++));
        });
    }

}
